<template>
  <Page name="额度审核">
    <div class="reject">
      <div class="con">
        <h4>驳回原因</h4>
        <textarea v-model="reason" placeholder="请输入驳回原因" @input="check"></textarea>
      </div>
      <div class="btn-wrap">
        <a
          class="btn btn-block btn-primary submit"
          :disabled="disabled"
          @click="submit($event)"
        >驳回申请</a>
      </div>
    </div>
  </Page>
</template>

<script>
import Page from "~/components/page";

export default {
  components: {
    Page
  },
  data() {
    return {
      reason: "",
      disabled: true
    };
  },
  methods: {
    check() {
      if (this.reason != "") {
        this.disabled = false;
      }
    },
    async submit() {
      if (this.reason == "") {
        this.$toast("请输入驳回原因");
        return false;
      }
      let { data: rs } = await this.$axios.post("?ct=api&ac=reject_apply", {
        bill_id: this.$utils.getUrlKey("bill_id"),
        reason: this.reason
      });
      if (rs.code == 0) {
        if (this.$utils.getUrlKey("from") == "leshell") {
          this.$router.push({ path: "/wealth" });
        } else {
          this.$router.push({ path: "/credit" });
        }
        this.$toast(rs.msg);
      } else {
        this.$toast(rs.msg);
      }
    }
  }
};
</script>

<style lang="less" scoped>
.reject {
  margin-top: 20px;
  .con {
    background: #fff;
    padding: 20px 30px;

    h4 {
      font-size: 30px;
      margin-bottom: 20px;
    }
    textarea {
      width: 100%;
      padding-top: 20px;
      height: 200px;
      outline: none;
      border:none;
      box-shadow: none;
    }
  }
  .btn-wrap {
    padding: 30px 30px;
    margin-top: 30px;
  }
}
</style>
